/*
 * @Author: zhaiyujia
 * @Date: 2022-11-16 00:43:31
 * @LastEditors: zhaiyujia
 * @LastEditTime: 2022-11-19 23:18:00
 * @Description: file content
 */

#include "Arduino.h"
#include "dht11.h"

dht11_def dht11;
uint8_t res;

void setup()
{
    Serial_begin(115200);
    delay(1500); // Wait for STC-ISP to open the serial port
    Serial_println("Hello Arduino-STC.");
    dht11_init(&dht11, D17);
}
void loop()
{
    delay(1000);
    res = dht11_run(&dht11);
    switch (res)
    {
    case 0:
        Serial_printf("Temperature:%buC, Humidity:%bu%%\r\n", dht11.temp, dht11.humi);
        break;
    case 1:
        Serial_printf("ERROR:offline!\r\n");
        break;
    case 2:
        Serial_printf("ERROR:timeout!\r\n");
        break;
    }
}
